Skip to content

Feat/yaml typespec support - #8

Merged
Artifizer merged 2 commits into
GlobalTypeSystem:mainfrom
KvizadSaderah:feat/yaml-typespec-support
Nov 22, 2025
Merged

Feat/yaml typespec support#8
Artifizer merged 2 commits into
GlobalTypeSystem:mainfrom
KvizadSaderah:feat/yaml-typespec-support

Conversation

@KvizadSaderah

@KvizadSaderah KvizadSaderah commented Nov 19, 2025

Copy link
Copy Markdown
Contributor

Summary

Renames Json* classes to Gts* and adds YAML/TypeSpec support.

Changes

1. Class Renaming:

  • JsonFileGtsFile, JsonEntityGtsEntity, JsonPathResolverGtsPathResolver, JsonEntityCastResultGtsEntityCastResult
  • Backward compatible via aliases

2. YAML Support:

  • Added PyYAML dependency
  • Support for .yaml and .yml files
  • Automatic format detection

3. TypeSpec:

  • Documentation for pre-compilation workflow

Testing

✅ All tests passed - YAML loading, JSON regression, backward compatibility confirmed

Files Changed

9 files, ~140 lines, 100% backward compatible

  - Renamed JsonFile → GtsFile
  - Renamed JsonEntity → GtsEntity
  - Renamed JsonPathResolver → GtsPathResolver
  - Renamed JsonEntityCastResult → GtsEntityCastResult
  - Added backward compatibility aliases in __init__.py
  - Updated all imports and type annotations across codebase

  BREAKING CHANGE: Class names changed from Json* to Gts*.
  Backward compatibility aliases provided for smooth migration.
  - Added PyYAML dependency (pyyaml>=6.0,<7)
  - Extended file reader to support .yaml and .yml extensions
  - Implemented format-aware file loading (YAML vs JSON)
  - Updated all class references in files_reader.py to use Gts* names
  - Added comprehensive format support documentation
  - Documented TypeSpec pre-compilation workflow

  YAML files are automatically detected and parsed. TypeSpec requires
  external compilation to JSON Schema before use.
Comment thread gts/README.md
npm install -g @typespec/compiler @typespec/json-schema

# Compile TypeSpec to JSON Schema
tsp compile --emit @typespec/json-schema your-schemas/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd like to have *.tsp files support right in the _load_file() and avoid this pre-processing. Could you please add it as separate PR?

Comment thread gts/README.md
@Artifizer
Artifizer merged commit 5c62a5c into GlobalTypeSystem:main Nov 22, 2025
KvizadSaderah added a commit to KvizadSaderah/gts-python that referenced this pull request Dec 12, 2025
Adds automatic compilation of TypeSpec files to JSON Schema:

- Added .tsp to valid_extensions for file discovery
- Created _compile_tsp() method using subprocess to call tsp compiler
- Falls back to npx @typespec/compiler if tsp not in PATH
- Gracefully skips .tsp files if compiler not available
- Updated README with native TypeSpec documentation

Requires: npm install -g @typespec/compiler @typespec/json-schema

Closes request from PR GlobalTypeSystem#8 review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants